<?php

use yii\db\Migration;

class m210915_111731_minerva_nets extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%minerva_nets}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id'",
            'auth' => "int(11) NOT NULL COMMENT '角色id'",
            'net_name' => "varchar(255) NULL DEFAULT '' COMMENT '网络名称'",
            'master_guid' => "varchar(255) NULL DEFAULT '' COMMENT '第一端口GUID'",
            'second_guid' => "varchar(255) NULL DEFAULT '' COMMENT '第二端口GUID'",
            'file_path' => "varchar(255) NULL COMMENT '默认目录'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='大数据系统-目标网络表'");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        $this->insert('{{%minerva_nets}}',['id'=>'5','auth'=>'1','net_name'=>'ere','master_guid'=>'45','second_guid'=>'80','file_path'=>'admin/user.html']);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%minerva_nets}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

